#include "StdAfx.h"
#include "TableStorage.h"


CTableStorage::CTableStorage(void)
	: m_createTable(_T(""))
	, m_checkTable(_T(""))
	, m_addColumne(_T(""))
	, m_checkColumne(_T(""))
	, m_createITrigger(_T(""))
	, m_checkITrigger(_T(""))
	, m_createUTrigger(_T(""))
	, m_checkUTrigger(_T(""))
	, m_createDTrigger(_T(""))
	, m_checkDTrigger(_T(""))
{
}


CTableStorage::~CTableStorage(void)
{
}



bool CTableStorage::CheckTable(CAdoConnection * pCN)
{
	bool bresult = true;
	int iorder = 0;
	CAdoRecordSet setUpdate;
	setUpdate.SetAdoConnection(pCN);
	while ( !setUpdate.Open( m_checkTable ) )
	{
		++iorder;
		if(iorder > 10)
		{
			return false;
		}
		pCN->Execute(m_createTable);
	}
	setUpdate.Close();
	return true;
}

bool CTableStorage::CheckColumne(CAdoConnection * pCN)
{
	bool bresult = true;
	int iorder = 0;
	CAdoRecordSet setUpdate;
	setUpdate.SetAdoConnection(pCN);
	while( !setUpdate.Open( m_checkColumne ) )
	{
		++iorder;
		if(iorder > 10)
		{
			return false;
		}
		pCN->Execute(m_addColumne);
	}
	setUpdate.Close();
	return true;
}

bool CTableStorage::CheckITrigger(CAdoConnection * pCN)
{
	bool bresult = true;
	int iorder = 0;
	CAdoRecordSet setUpdate;
	setUpdate.SetAdoConnection(pCN);
	while((! setUpdate.Open( m_checkITrigger )) || (setUpdate.GetRecordCount() < 1 ))
	{
		++iorder;
		if(iorder > 10)
		{
			return false;
		}
		pCN->Execute(m_createITrigger);
	}
	setUpdate.Close();
	return true;
}

bool CTableStorage::CheckUTrigger(CAdoConnection * pCN)
{
	bool bresult = true;
	int iorder = 0;
	CAdoRecordSet setUpdate;
	setUpdate.SetAdoConnection(pCN);
	while((! setUpdate.Open( m_checkUTrigger )) || (setUpdate.GetRecordCount() < 1 ))
	{
		++iorder;
		if(iorder > 10)
		{
			return false;
		}
		pCN->Execute(m_createUTrigger);
	}
	setUpdate.Close();
	return true;
}

bool CTableStorage::CheckDTrigger(CAdoConnection * pCN)
{
	bool bresult = true;
	int iorder = 0;
	CAdoRecordSet setUpdate;
	setUpdate.SetAdoConnection(pCN);
	while((! setUpdate.Open( m_checkDTrigger )) || (setUpdate.GetRecordCount() < 1 ))
	{
		++iorder;
		if(iorder > 10)
		{
			return false;
		}
		pCN->Execute(m_createDTrigger);
	}
	setUpdate.Close();
	return true;
}


// CheckTableInfo
bool CTableStorage::CheckTableInfo(void)
{
	return false;
}
